package com.csun.cmny.provider.service.impl;

import com.csun.cmny.core.support.BaseService;
import com.csun.cmny.provider.dao.OmcDisinfectionMethodMapper;
import com.csun.cmny.provider.model.domain.OmcDisinfectionMethod;
import com.csun.cmny.provider.model.domain.OmcDisinfectionPosition;
import com.csun.cmny.provider.model.dto.disinfectionMethod.DisinfectionMethodSelectDto;
import com.csun.cmny.provider.model.vo.disinfectionMethod.DisinfectionMethodVo;
import com.csun.cmny.provider.model.vo.disinfectionPosition.HuaLongEveryDsftMethodVo;
import com.csun.cmny.provider.service.OmcDisinfectionMethodService;
import com.csun.cmny.provider.service.OmcDisinfectionPositionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
@Transactional
public class OmcDisinfectionMethodServiceImpl extends BaseService<OmcDisinfectionMethod> implements OmcDisinfectionMethodService {

    @Resource
    private OmcDisinfectionMethodMapper disinfectionMethodMapper;

    @Resource
    private OmcDisinfectionPositionService positionService;

    @Override
    public List<DisinfectionMethodVo> selectDisinfectionMethod(DisinfectionMethodSelectDto disinfectionMethodSelectDto) {
        List<DisinfectionMethodVo> list = disinfectionMethodMapper.selectDisinfectionMethod(disinfectionMethodSelectDto);



        for (DisinfectionMethodVo disinfectionMethodVo : list) {
            OmcDisinfectionPosition omcDisinfectionPosition = new OmcDisinfectionPosition();
            omcDisinfectionPosition.setDisinfectionMethodId(disinfectionMethodVo.getId());

            List<OmcDisinfectionPosition> select = positionService.select(omcDisinfectionPosition);

            disinfectionMethodVo.setPositions(select);
        }
        return list;
    }

    /**
     * 根据机构Id查询消毒方式
     *
     * @param groupId the group id
     *
     * @return the list.
     */
    @Override
    public List<HuaLongEveryDsftMethodVo> queryByGroupId(Long groupId) {

        return disinfectionMethodMapper.queryByGroupId(groupId);
    }
}
